package com.ydzt.fanka.server.space.consumer;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.ydzt.fanka.server.domain.ParamDefine;

//消费者线程池  将队列中的报文解包入库 并进行具体的处理
public class SocketConsumerPool {
	private static SocketConsumerPool processPool;
	private List<SocketConsumer> processList = new ArrayList<SocketConsumer>();
	private int maxNum = 0;
	private int currNum = 0;
	//private 
	private SocketConsumerPool(){
	}
	
	//private SocketConsumerPool();
	public static SocketConsumerPool getInstans(int maxNum){
		if(null == processPool){
			processPool = new SocketConsumerPool();
			processPool.maxNum = maxNum;
		}
		return processPool;
	}
	
	public void initProcessPool(HashMap<String , ParamDefine> paramDefine,Connection conn){
		while(currNum < maxNum){
			SocketConsumer process = new SocketConsumer(paramDefine,conn);
			process.start();
			processList.add(process);
			currNum ++;
		}
	}
	
	
	public int getMaxNum(){
		return maxNum;
	}
	public int getCurrNum(){
		return currNum;
	}
}
